/*
 * ========================================================
 * Copyright(c) 2014 杭州偶尔科技-版权所有
 * ========================================================
 * 本软件由杭州偶尔科技所有, 未经书面许可, 任何单位和个人不得以
 * 任何形式复制代码的部分或全部, 并以任何形式传播。
 * 公司网址
 * 
 * 			http://www.kkkd.com/
 * 
 * ========================================================
 */
package com.simon.mengkou.ui.base;

import android.os.Bundle;

import com.ouertech.android.agm.lib.ui.base.defaults.fragment.BaseSystemFragment;
import com.simon.mengkou.ui.activity.NDNiudanActivity;

/**
 * @author : Zhenshui.Xia
 * @since : 2016/1/21.
 * desc    : 扭蛋片段界面基类
 */
public abstract class BaseNiudanFragment extends BaseSystemFragment{
    protected NDNiudanActivity mActivity;

    /**
     * 返回
     */
    public abstract void onBackPressed();

    @Override
    protected void init(Bundle savedInstanceState) {
        super.init(savedInstanceState);
        mActivity = (NDNiudanActivity) getBaseActivity();
    }

    @Override
    public void onResume() {
        super.onResume();
        //设置当前栈顶的片段
        mActivity.setStackTopFragment(this);
    }

    /**
     * 设置是否显示门
     * @param visible
     */
    public void setDoorVisible(boolean visible) {
        mActivity.setDoorVisible(visible);
    }

    /**
     * 退出界面
     */
    public void finish() {
        mActivity.finish();
    }

    /**
     * 打开门
     * @param listener
     */
    public void openDoor(final NDNiudanActivity.OnDoorOpenListener listener) {
        openDoor(listener, 0);
    }

    /**
     * 打开门
     * @param listener
     * @param delay
     */
    public void openDoor(final NDNiudanActivity.OnDoorOpenListener listener, long delay) {
        mActivity.openDoor(listener, delay);
    }

    /**
     * 关闭门
     * @param listener
     */
    public void closeDoor(final NDNiudanActivity.OnDoorCloseListener listener) {
        mActivity.closeDoor(listener, 0);
    }

    /**
     * 关闭门
     * @param listener
     * @param delay
     */
    public void closeDoor(final NDNiudanActivity.OnDoorCloseListener listener, long delay) {
        mActivity.closeDoor(listener, delay);
    }

}
